package com.yanqu.road.entity.activity.carptrip.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.activity.carptrip.UserCarpTripEvent;

import java.math.BigInteger;
import java.util.*;

@FieldTypeAnnotation(tableName = "t_u_carp_trip_data")
public class UserCarpTripData extends DataObject {

    @FieldTypeAnnotation(select = true, update = true, desc = "活动ID")
    private int activityId;

    @FieldTypeAnnotation(select = true, update = true, desc = "玩家ID")
    private long userId;

    @FieldTypeAnnotation(desc = "身份经验值")
    private BigInteger exp = BigInteger.ZERO;

    @FieldTypeAnnotation(desc = "积分")
    private int score;

    @FieldTypeAnnotation(desc = "能力值/实力")
    private BigInteger ability = BigInteger.ZERO;

    @FieldTypeAnnotation(desc = "体力")
    private int power;

    @FieldTypeAnnotation(desc = "上次恢复时间")
    private long lastRecoverPowerTime;

    @FieldTypeAnnotation(desc = "抽奖次数")
    private int drawTimes;

    @FieldTypeAnnotation(desc = "可发射次数")
    private int launchTimes;

    @FieldTypeAnnotation(desc = "当前层")
    private int cellNum;

    @FieldTypeAnnotation(desc = "抽奖道具统计")
    private Map<Integer, Integer> drawCountMap = new HashMap<>();

    @FieldTypeAnnotation(desc = "爬塔事件")
    private UserCarpTripEvent event = new UserCarpTripEvent();

    @FieldTypeAnnotation(desc = "合成游戏的数据")
    private String gameData = "";

    @FieldTypeAnnotation(desc = "幻想层-当前层")
    private int topCellNum;

    @FieldTypeAnnotation(desc = "幻想层-历史")
    private List<Integer> topCellList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "合成游戏-已过关卡-领取过奖励的")
    private Map<Integer, Boolean> dragonIdList = new HashMap<>();

    @FieldTypeAnnotation(desc = "弹珠等级")
    private int drawUpLv;

    @FieldTypeAnnotation(desc = "大奖进度")
    private int drawProcess;

    @FieldTypeAnnotation(desc = "鱼籽")
    private int drawExp;

    @FieldTypeAnnotation(desc = "战报最后读取时间")
    private long lastReadTime;

    @FieldTypeAnnotation(desc = "已经处理的层")
    private List<Integer> preHandleList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "抽奖奖励-暂存")
    private Map<Integer, String> drawRewardMap = new HashMap<>();
    @FieldTypeAnnotation(desc = "客户端通知的龙宫探宝是否出现过")
    private int clientSave;

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if(this.activityId != activityId) {
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public BigInteger getExp() {
        return exp;
    }

    public void setExp(BigInteger exp) {
        if(this.exp != exp) {
            this.exp = exp;
            setUpdateOption();
        }
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        if(this.score != score) {
            this.score = score;
            setUpdateOption();
        }
    }

    public BigInteger getAbility() {
        return ability;
    }

    public void setAbility(BigInteger ability) {
        if(this.ability != ability) {
            this.ability = ability;
            setUpdateOption();
        }
    }

    public int getPower() {
        return power;
    }

    public void setPower(int power) {
        if(this.power != power) {
            this.power = power;
            setUpdateOption();
        }
    }

    public long getLastRecoverPowerTime() {
        return lastRecoverPowerTime;
    }

    public void setLastRecoverPowerTime(long lastRecoverPowerTime) {
        if(this.lastRecoverPowerTime != lastRecoverPowerTime) {
            this.lastRecoverPowerTime = lastRecoverPowerTime;
            setUpdateOption();
        }
    }

    public int getDrawTimes() {
        return drawTimes;
    }

    public void setDrawTimes(int drawTimes) {
        if(this.drawTimes != drawTimes) {
            this.drawTimes = drawTimes;
            setUpdateOption();
        }
    }

    public int getLaunchTimes() {
        return launchTimes;
    }

    public void setLaunchTimes(int launchTimes) {
        if(this.launchTimes != launchTimes) {
            this.launchTimes = launchTimes;
            setUpdateOption();
        }
    }

    public int getCellNum() {
        return cellNum;
    }

    public void setCellNum(int cellNum) {
        if(this.cellNum != cellNum) {
            this.cellNum = cellNum;
            setUpdateOption();
        }
    }

    public UserCarpTripEvent getEvent() {
        return event;
    }

    public void setEvent(UserCarpTripEvent event) {
        if(this.event != event) {
            this.event = event;
            setUpdateOption();
        }
    }

    public String getGameData() {
        return gameData;
    }

    public void setGameData(String gameData) {
        if(!Objects.equals(this.gameData, gameData)) {
            this.gameData = gameData;
            setUpdateOption();
        }
    }

    public int getTopCellNum() {
        return topCellNum;
    }

    public void setTopCellNum(int topCellNum) {
        if(this.topCellNum != topCellNum) {
            this.topCellNum = topCellNum;
            setUpdateOption();
        }
    }

    public List<Integer> getTopCellList() {
        return topCellList;
    }

    public void setTopCellList(List<Integer> topCellList) {
        this.topCellList = topCellList;
        setUpdateOption();
    }

    public void addTopCell(int cellNum){
        if(!topCellList.contains(cellNum)){
            topCellList.add(cellNum);
            setUpdateOption();
        }
    }

    public Map<Integer, Boolean> getDragonIdList() {
        return dragonIdList;
    }

    public void setDragonIdList(Map<Integer, Boolean> dragonIdList) {
        this.dragonIdList = dragonIdList;
        setUpdateOption();
    }

    public int getDrawUpLv() {
        return drawUpLv;
    }

    public void setDrawUpLv(int drawUpLv) {
        if(this.drawUpLv != drawUpLv) {
            this.drawUpLv = drawUpLv;
            setUpdateOption();
        }
    }

    public int getDrawProcess() {
        return drawProcess;
    }

    public void setDrawProcess(int drawProcess) {
        if(this.drawProcess != drawProcess) {
            this.drawProcess = drawProcess;
            setUpdateOption();
        }
    }

    public int getDrawExp() {
        return drawExp;
    }

    public void setDrawExp(int drawExp) {
        if(this.drawExp != drawExp) {
            this.drawExp = drawExp;
            setUpdateOption();
        }
    }

    public long getLastReadTime() {
        return lastReadTime;
    }

    public void setLastReadTime(long lastReadTime) {
        if(this.lastReadTime != lastReadTime) {
            this.lastReadTime = lastReadTime;
            setUpdateOption();
        }
    }

    public List<Integer> getPreHandleList() {
        return preHandleList;
    }

    public void setPreHandleList(List<Integer> preHandleList) {
        if(this.preHandleList != preHandleList) {
            this.preHandleList = preHandleList;
            setUpdateOption();
        }
    }

    public void addPreHandle(int cellId){
        if(!this.preHandleList.contains(cellId)){
            this.preHandleList.add(cellId);
            setUpdateOption();
        }
    }

    public Map<Integer, String> getDrawRewardMap() {
        return drawRewardMap;
    }

    public void setDrawRewardMap(Map<Integer, String> drawRewardMap) {
        this.drawRewardMap = drawRewardMap;
        setUpdateOption();
    }

    public Map<Integer, Integer> getDrawCountMap() {
        return drawCountMap;
    }

    public void setDrawCountMap(Map<Integer, Integer> drawCountMap) {
        this.drawCountMap = drawCountMap;
        setUpdateOption();
    }

    public void addDrawCount(int id, int val){
        int old = drawCountMap.getOrDefault(id, 0);
        drawCountMap.put(id, old + val);
        setUpdateOption();
    }

    public int getClientSave() {
        return clientSave;
    }

    public void setClientSave(int clientSave) {
        this.clientSave = clientSave;
        setUpdateOption();
    }
}
